package com.yang.studentsapp.ui.campus;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.ThemedSpinnerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.nostra13.universalimageloader.utils.L;
import com.yang.studentsapp.CampusSociety;
import com.yang.studentsapp.PresenterSociety;
import com.yang.studentsapp.R;
import com.yang.studentsapp.presenter.IView;
import com.yang.studentsapp.presenter.IViewSuccess;
import com.yang.studentsapp.ui.adapter.BaseAdapter;
import com.yang.studentsapp.ui.adapter.BaseViewHolder;
import com.yang.studentsapp.ui.adapter.SocietyAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ${Ян-Вэнь-Чао} on 2016/10/10.
 * 社会
 */
public class SocietyFragment extends Fragment implements IView{

    private ListView listView;
    private SocietyAdapter mAdapter;
    PresenterSociety presenterSociety;


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_society, container, false);
        listView = (ListView) view.findViewById(R.id.listView_society);


        iii();
        return view;
    }

    private void iii() {

        mAdapter = new SocietyAdapter(getContext(), null);
        listView.setAdapter(mAdapter);
        presenterSociety = new PresenterSociety(this);
        presenterSociety.getSocietyNews(new IViewSuccess<List<CampusSociety>>() {
            @Override
            public void onSuccess(List<CampusSociety> data) {
                Toast.makeText(getContext(),"正在刷新列表",Toast.LENGTH_SHORT).show();
                mAdapter.update(data);
            }
        });
    }


    @Override
    public void onFail(String msg) {
        Toast.makeText(getContext(),"失败",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onStart(String msg) {
        Toast.makeText(getContext(),"开始获取",Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onError(String msg) {
        Toast.makeText(getContext(),"错误",Toast.LENGTH_SHORT).show();
    }


}
